import 'package:flutter/cupertino.dart';
import 'package:oi_ai_tool/common/IconFontIcons.dart';
import 'package:oi_ai_tool/route/oi_route.dart';

class OiBack extends StatelessWidget {
  bool? isBackHome;
  String? routeName;
  OiBack({super.key, this.isBackHome = true, this.routeName = Routes.Initials});

  @override
  Widget build(BuildContext context) {
    return CupertinoButton(
        child: const Icon(IconFontIcons.iconFenxiang),
        onPressed: () {
          if (isBackHome != null && isBackHome!) {
            OiRoute.off(Routes.Initials);
            return;
          } else if (routeName != null &&
              !(routeName!.compareTo(Routes.Initials) == 0)) {
            OiRoute.off(routeName!);
            return;
          } else {
            OiRoute.back();
          }
        });
  }
}
